﻿/*****************************************************************//**
 * @file    FITKGraphObjectSet.h
 * @brief   Mesh set data exchange class.
 * 
 * @sa
 * FITKSetSurfPolyProvider
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-04-01
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTSET_H__
#define __FITKGRAPHOBJECTSET_H__

#include "FITKGraphObjectHighlightBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class QVariant;

class vtkUnstructuredGrid;

class FITKGraphActor;

namespace Interface
{
    class FITKModelSet;
    class FITKAbstractAssInstance;
    class FITKAbaAssembly;
}

namespace AbaqusData
{
    class FITKAbaqusPart;
}

namespace Exchange
{
    /**
     * @brief   Mesh highlight graph object class for 'set'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-04-01
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectSet : public FITKGraphObjectHighlightBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectSet, FITKGraphObjectHighlightBase);
        FITKCLASS(Exchange, FITKGraphObjectSet);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   set: The input mesh set data need to be exchanged
         * @param   details: The addin information needed ( The assembly-instance ID ) [default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-01
         */
        FITKGraphObjectSet(AbaqusData::FITKDataCase* caseData, Interface::FITKModelSet* set, QVariant details = QVariant());

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-01
         */
        virtual ~FITKGraphObjectSet();

        /**
         * @brief   Update the visibility of set.
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-14
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Update the visibility with data object's visibility.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-15
         */
        void updateVisibility() override;

        /**
         * @brief   If the graph object has relation with the given data object id.[override]
         * @param   dataObjId: The data object id
         * @return  Has relation
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        bool isRelatedTo(int dataObjId) override;

    private:
        /**
         * @brief   Generate the set and its's sub-sets' actors.
         * @param   set: The set data object
         * @param   instanceId: The instance id( Id need )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-23
         */
        void generateSetActor(Interface::FITKModelSet* set, int instanceId = -1);

        /**
         * @brief   Clear actors and all data about the set data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void clearData();

    private:
        /**
         * @brief   If this set is belonged to an assembly-instance, this id will be not -1.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-09
         */
        int m_instanceId = -1;

        /**
         * @brief   The set and sub-sets' grid data list.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-04-23
         */
        QList<vtkUnstructuredGrid*> m_setGridList;

        /**
         * @brief   The actor and its model id hash.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-14
         */
        QHash<FITKGraphActor*, int> m_actorModelIdHash;

        /**
         * @brief   The sub set id list.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        QList<int> m_subSetIds;

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTSET_H__
